package com.easybuy.service.impl;

import java.util.List;

import com.easybuy.dao.ProductDao;
import com.easybuy.dao.impl.ProductDaoImpl;
import com.easybuy.entity.Product;
import com.easybuy.service.ProductService;

public class ProductServiceImpl implements ProductService {
	private ProductDao dao = new ProductDaoImpl();
	@Override
	public List<Product> findByCategoryId(int categoryId,int categoryLevel,int currPage, int pageSize) {

		int startIndex = (currPage-1)*pageSize;
		return dao.findByCategoryId(categoryId,categoryLevel,startIndex,pageSize);
	}
	
	
	@Override
	public int findCountByCategoryId(int categoryId, int categoryLevel) {
		// TODO Auto-generated method stub
		return dao.findCountByCategoryId(categoryId, categoryLevel);
	}


	@Override
	public Product findById(int id) {
		// TODO Auto-generated method stub
		return dao.findById(id);
	}


	@Override
	public int subStock(int productId, int quantity) {
		// TODO Auto-generated method stub
		return dao.subStock(productId, quantity);
	}


	@Override
	public List<Product> findList(int currPageNo, int pageSize) {
		int startIndex = (currPageNo-1)*pageSize;
		return dao.findList(startIndex,pageSize);
	}


	@Override
	public int findCount() {
		// TODO Auto-generated method stub
		return dao.findCount();
	}

}
